'use strict';

var React = require('react/addons');
var Router = require('react-router');

var Route = Router.Route;
var DefaultRoute = Router.DefaultRoute;
var Redirect = Router.Redirect;


var App = React.createFactory(require('./components/layouts/app.jsx'));
var Do = React.createFactory(require('./components/layouts/do.jsx'));

var MyPage =  React.createFactory(require('./components/page/myView.jsx'));
var MyTabOne =  React.createFactory(require('./components/page/myView/solved1.jsx'));
var MyTabTwo =  React.createFactory(require('./components/page/myView/solved2.jsx'));
var MyTabThere =  React.createFactory(require('./components/page/myView/solved3.jsx'));
var Dialogue =  React.createFactory(require('./components/page/myView/dialogue.jsx'));


var QuestionsPage = React.createFactory(require('./components/page/questionsView.jsx'));
var QuestionsTabOne = React.createFactory(require('./components/page/questionsView/QuestionsTabOne.jsx'));
var Qiangda = React.createFactory(require('./components/page/questionsView/Qiangda.jsx'));

var UserPage = React.createFactory(require('./components/page/userView.jsx'));
var UserTabOne = React.createFactory(require('./components/page/userView/UserTabOne.jsx'));

var DataPage = React.createFactory(require('./components/page/dataView.jsx'));
var DataTabOne = React.createFactory(require('./components/page/dataView/DataTabOne.jsx'));

var CenterPage = React.createFactory(require('./components/page/centerView.jsx'));
var CenterService = React.createFactory(require('./components/page/centerView/CenterService.jsx'));
var CenterBank = React.createFactory(require('./components/page/centerView/CenterBank.jsx'));
var CenterProfit = React.createFactory(require('./components/page/centerView/CenterProfit.jsx'));
var CenterAuth = React.createFactory(require('./components/page/centerView/CenterAuth.jsx'));
var CenterHead = React.createFactory(require('./components/page/centerView/CenterHead.jsx'));
var CenterPwd = React.createFactory(require('./components/page/centerView/CenterPwd.jsx'));
var CenterDoctor = React.createFactory(require('./components/page/centerView/CenterDoctor.jsx'));


var LoginPage = React.createFactory(require('./components/page/login.jsx'));


/* jshint ignore:start */
var Routes = (
  <Route name="app" path="/" handler={ App }>

    <Route name="login" handler={ LoginPage } />

    <Route name="do" handler={ Do }>

      <Route name="my" handler={MyPage}>
      	<Route name="MyTabOne" handler={MyTabOne}/>
      	<Route name="MyTabTwo" handler={MyTabTwo}>
          </Route>
          {/*解决中和已解决公用的对话框*/}
            <Route name="Dialogue" path="/Dialogue/:type/:id" handler={Dialogue}/>
      	    <Route name="MyTabThere" handler={MyTabThere}>
        </Route>
      	<DefaultRoute handler={MyTabOne}/>
      </Route>

      <Route name="questions" handler={QuestionsPage}>
      	<Route name="QuestionsTabOne" handler={QuestionsTabOne}/>
               <Route name="Qiangda" path="/Qiangda/:mid" handler={Qiangda}/>
      	<DefaultRoute handler={QuestionsTabOne}/>
      </Route>

      <Route name="user" handler={UserPage}>
        <Route name="UserTabOne" handler={UserTabOne}/>
        <DefaultRoute handler={UserTabOne}/>
      </Route>

      <Route name="data" handler={DataPage}>
        <Route name="DataTabOne" handler={DataTabOne}/>
        <DefaultRoute handler={DataTabOne}/>
      </Route>

      <Route name="center" handler={CenterPage}>
        <Route name="CenterService" handler={CenterService}/>
        <Route name="CenterBank" handler={CenterBank}/>
        <Route name="CenterProfit" handler={CenterProfit}/>
        <Route name="CenterAuth" handler={CenterAuth}/>
        <Route name="CenterHead" handler={CenterHead}/>
        <Route name="CenterPwd" handler={CenterPwd}/>
        <Route name="CenterDoctor" handler={CenterDoctor}/>
        <DefaultRoute handler={CenterService}/>
      </Route>
    </Route>

    <Redirect from="/" to="MyTabOne" />

  </Route>
);


var content = document.getElementById('app-wrapper');

Router.run(Routes, function (Handler, state) {
	 var params = state.params;
	  React.render(<Handler params={params}/>, content);
});
/* jshint ignore:end */
module.exports = Router;